home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / wot-20080519-fx.xpi / chrome / wot.jar / content / status.js < prev    next >
Text File  |  2008-05-07  |  3KB  |  111 lines

  1. /*
  2.     status.js
  3.  
  4.     Copyright ⌐ 2005, 2006, 2007  Against Intuition, Inc. <info@mywot.com>
  5. */
  6.  
  7. var wot_status =
  8. {
  9.     init: function()
  10.     {
  11.     },
  12.  
  13.     set: function(status, description)
  14.     {
  15.         try {
  16.             if (wot_update.isavailable()) {
  17.                 status += "-update";
  18.             } else if (wot_api_query.message.length > 0 &&
  19.                 wot_api_query.message_type.length > 0 &&
  20.                 wot_api_query.message_id != wot_prefs.last_message &&
  21.                 wot_api_query.message_id != WOT_SERVICE_XML_QUERY_MSG_ID_MAINT) {
  22.                 status += "-update";
  23.             }
  24.  
  25.             /* Set tooltip and status */
  26.             var mainwnd = document.getElementById("main-window");
  27.             if (mainwnd) {
  28.                 mainwnd.setAttribute("wot-status", status);
  29.             }
  30.  
  31.             var tooltip = document.getElementById("wot-tooltip-text");
  32.             if (tooltip) {
  33.                 tooltip.value = description;
  34.             }
  35.  
  36.             /* Update display */
  37.             wot_ui.update(description);
  38.         } catch (e) {
  39.             dump("wot_status.set: failed with " + e + "\n");
  40.         }
  41.     },
  42.  
  43.     update: function()
  44.     {
  45.         try {
  46.             if (!wot_api_register.ready) {
  47.                 return;
  48.             }
  49.  
  50.             var reputation = -1;
  51.  
  52.             if (wot_cache.isok(wot_core.hostname)) {
  53.                 reputation = wot_cache.get(wot_core.hostname,
  54.                                 "reputation_0");
  55.             }
  56.  
  57.             if (reputation > WOT_MAX_REPUTATION) {
  58.                 reputation = WOT_MAX_REPUTATION;
  59.             }
  60.  
  61.             /* Set status and description */
  62.             var status, description, testimonies = false;
  63.  
  64.             for (var i = 0; i < WOT_APPLICATIONS; ++i) {
  65.                 if (wot_cache.get(wot_core.hostname, "testimony_" + i) >= 0) {
  66.                     testimonies = true;
  67.                     break;
  68.                 }
  69.             }
  70.  
  71.             if (reputation >= WOT_MIN_REPUTATION_5) {
  72.                 status = "5";
  73.             } else if (reputation >= WOT_MIN_REPUTATION_4) {
  74.                 status = "4";
  75.             } else if (reputation >= WOT_MIN_REPUTATION_3) {
  76.                 status = "3";
  77.             } else if (reputation >= WOT_MIN_REPUTATION_2) {
  78.                 status = "2";
  79.             } else if (reputation >= 0) {
  80.                 status = "1";
  81.             } else {
  82.                 status = "0";
  83.             }
  84.  
  85.             description = wot_util.getstring("description_rating_" + status);
  86.  
  87.             if (testimonies) {
  88.                 status += "-testimony";
  89.             }
  90.  
  91.             this.set(status, description);
  92.             var type = wot_warning.isdangerous(wot_core.hostname, true);
  93.  
  94.             if (type == WOT_WARNING_NOTIFICATION ||
  95.                     type == WOT_WARNING_DOM) {
  96.                 window.setTimeout(wot_browser.show_warning,
  97.                     WOT_DELAY_WARNING, wot_core.hostname,
  98.                     wot_util.getstring("warning_message"));
  99.             }
  100.             if (type == WOT_WARNING_DOM) {
  101.                 wot_warning.add(wot_core.hostname,
  102.                     getBrowser().selectedBrowser.contentDocument);
  103.             }
  104.         } catch (e) {
  105.             dump("wot_status.update: failed with " + e + "\n");
  106.         }
  107.     }
  108. };
  109.  
  110. wot_status.init();
  111.